Skip to content

Pgvector port - #182

Open
tozzen0121 wants to merge 10 commits into
masterfrom
pgvector-port
Open

Pgvector port#182
tozzen0121 wants to merge 10 commits into
masterfrom
pgvector-port

Conversation

@tozzen0121

Copy link
Copy Markdown

No description provided.

Comment thread .env.example Outdated
PINECONE_ENVIRONMENT=environment
PINECONE_KEY=key

# POSTGRE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing s

Comment thread requirements.txt Outdated
replicate==0.18.1 No newline at end of file
replicate==0.18.1
psycopg[binary]
psycopg2-binary No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need new line

Comment thread .env.example Outdated
PINECONE_KEY=key

# POSTGRE
POSTGRE_HOST=localhost

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be POSTGRES

get_postgre_cursor().execute('SELECT * FROM embedding ORDER BY values <-> %s LIMIT 50', (np.array(query_vector),))
query_matches = get_postgre_cursor().fetchall()

# query(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove any dead code

used_messages = list(
filter(
lambda match: match["id"]
lambda match: match[2]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move magic number to constant

Comment thread requirements.txt Outdated
gunicorn==20.1.0
replicate==0.18.1 No newline at end of file
replicate==0.18.1
psycopg[binary]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix these versions

from flask import Flask, request, jsonify
from .config import get_google_tasks_service_account
from .external_services.pinecone import get_pinecone_index
from .external_services.postgre_vector import get_postgre_cursor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postgre-> postgres

@YuraLukashik YuraLukashik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a way to switch between the existing implementation with Pinecone and the new one with Postgres. Some level of abstraction is needed for that.

Comment thread README.md
Comment thread README.md Outdated
Comment on lines +114 to +116
***


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that space for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me remove one line. is it ok?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these 3 new lines?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is my mistake, let me remove them.

Comment thread requirements.txt
register_vector(cur)

# cur.execute('DROP TABLE IF EXISTS embedding')
cur.execute('CREATE TABLE IF NOT EXISTS embedding (id bigserial PRIMARY KEY, namespace text, chunk_id text, metadata text, values vector)')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really do that during every connection?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you know app will not create table if there is already exist. Let me find best way

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know that.


conn = None
try:
conn = psycopg2.connect(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a connection only when it's needed, not when Python modules are loaded.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it



def delete_pinecone_embedding(embeddings: list[Embedding], pinecone_index, pinecone_namespace):
def delete_db_embedding(embeddings: List[Embedding], postgres_cursor, namespace):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we make it abstract?

Comment thread src/semantic_search/semantic_search/load_messages.py
is_actual_message, \
slack_names_map, filter_messages, load_previous_messages, load_subsequent_messages

import numpy as np

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used in this file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me remove

Comment thread src/semantic_search/semantic_search/query.py Outdated
Comment thread src/semantic_search/semantic_search/query.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants